#pragma once
#include "../IModule.h"
#include <QMap>

class ModuleMgr
{
    struct ModuleDef
    {
        QString id;
        QString dllName;
        QString dir;
        int		loadBehavior = 1;//0: load startup; 1: application ready. 2: as needed
        IModule* module = nullptr;
    };
public:
    IModule* module(const QString& id);
    void unloadModules();
    static ModuleMgr& instance();

private:
	ModuleMgr();
	~ModuleMgr();

    void loadModules();
    IModule* loadModule(const QString& id);

private:
    QMap<QString, ModuleDef>    m_modules;
};

